home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 June: Reference Library / Dev.CD Jun 99 RL Disk 1.toast / Technical Documentation / Develop / develop Issue 26 / develop Issue 26 code / SOM and ListPart / ListPart DR4 / Source / ListPart.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-24  |  11.2 KB  |  343 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ListPart.h
  3.  
  4.     Contains:    Sample part editor class implementation
  5.  
  6.     Written by:    Steve Smith
  7.     
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11. #ifndef _LISTPART_
  12. #define _LISTPART_
  13.  
  14. // -- Compiler/Preprocessor Switches --
  15.  
  16. #ifndef _COMPILERDEFS_
  17. #include "CompDefs.h"
  18. #endif
  19.  
  20. // -- OpenDoc Includes --
  21.  
  22. #ifndef _ODTYPES_
  23. #include <ODTypes.h>
  24. #endif
  25.  
  26. // -- Macintosh Includes --
  27.  
  28. #ifndef __TYPES__
  29. #include <Types.h>
  30. #endif
  31.  
  32. #ifndef __QDOFFSCREEN__
  33. #include <QDOffScreen.h>
  34. #endif
  35.  
  36. #ifndef SOM_ACF_DevServ_som_ListPart_xh
  37. #include "som_ListPart.xh"
  38. #endif
  39.  
  40. // -- Forward Declarations --
  41.  
  42. class Environment;
  43. class ODFacet;
  44. class ODFocusSet;
  45. class ODFrame;
  46. class ODMenuBar;
  47. class ODShape;
  48. class ODStorageUnit;
  49. class ODWindow;
  50. class CList;
  51.  
  52. struct WindowProperties;
  53.  
  54. extern Environment* gEv;
  55. extern ODFacet* gFacet;
  56. extern ControlHandle gControl;
  57. extern ODPart* gMySelf;
  58. extern short gInitDelta, gTempoVal;
  59. extern char gTextVersion[71];
  60.  
  61. #define mabs(val) (((val)>0)?(val):(-(val)))
  62.  
  63. #define kNull 1
  64. #define kPassive 2
  65. #define kActive 3
  66. #define kMultiple 4
  67.  
  68. #define kMargin 6
  69.  
  70. #define kODPropListListIndex    "List:Property:ListIndex"
  71. #define kODPropListNbLines        "List:Property:NbLines"
  72. #define kODPropListLineHeight    "List:Property:LineHeight"
  73. #define kODPropListLineWidth    "List:Property:LineWidth"
  74. #define kODPropListLineDepth    "List:Property:LineDepth"
  75. #define kODPropListAutoThumb    "List:Property:AutoThumb"
  76. #define kODPropListWantKey        "List:Property:WantKey"
  77. #define kODPropListKind            "List:Property:Kind"
  78. #define kODPropListSel            "List:Property:Sel"
  79. #define kODPropListMul            "List:Property:Mul"
  80.  
  81. #define kListShort "List:Kind:Short"
  82. #define kListChars "List:Kind:Chars"
  83.  
  84. typedef struct
  85.     {
  86.     ControlHandle    fListCtl;
  87.     short            fNbVis;
  88.     Rect            fUsedRect;
  89.     } ListFacetInfo, *ListFacetInfoPtr;
  90.  
  91. #pragma import on
  92.  
  93. class ListPart {
  94.     
  95.       //==================================
  96.       // Overridden Public ODPart Methods
  97.       //==================================
  98.     public:
  99.     
  100.     ListPart();
  101.     virtual ~ListPart();
  102.     
  103.     // -- Initialization --
  104.     
  105.     void        InitPart(Environment* ev, ODStorageUnit* storageUnit,
  106.                                         ODPart* partWrapper, ACF_DevServ_som_ListPart* somSelf);
  107.     void        InitPartFromStorage(Environment* ev, ODStorageUnit* storageUnit,
  108.                                         ODPart* partWrapper, ACF_DevServ_som_ListPart* somSelf);
  109.     
  110.     // -- Storage --
  111.     
  112.     void        Release(Environment* ev);
  113.     void        ReleaseAll(Environment* ev);
  114.     ODSize        Purge(Environment* ev, ODSize size);
  115.     void        Externalize(Environment* ev);
  116.     void        ExternalizeKinds(Environment* ev, ODTypeList* kindset);
  117.     void        ChangeKind(Environment* ev, ODType kind);
  118.     void        CloneInto(Environment* ev, ODDraftKey key,
  119.                                         ODStorageUnit* destinationSU,
  120.                                         ODFrame* initiatingFrame);
  121.     void        WritePartInfo(Environment* ev, ODInfoType partInfo,
  122.                                         ODStorageUnitView* storageUnitView);
  123.     ODInfoType    ReadPartInfo(Environment* ev, ODFrame* frame,
  124.                                         ODStorageUnitView* storageUnitView);
  125.     void        ClonePartInfo(Environment *ev, ODDraftKey key, ODInfoType partInfo,
  126.                                         ODStorageUnitView* storageUnitView,
  127.                                         ODFrame* scopeFrame);
  128.     
  129.     // -- Layout --
  130.     
  131.     void        DisplayFrameAdded(Environment* ev, ODFrame* frame);
  132.     void        DisplayFrameRemoved(Environment* ev, ODFrame* frame);
  133.     void        DisplayFrameClosed(Environment* ev, ODFrame* frame);
  134.     void        DisplayFrameConnected(Environment* ev, ODFrame* frame);
  135.     void        AttachSourceFrame(Environment* ev, ODFrame* frame,
  136.                                         ODFrame* sourceFrame);
  137.     void        ViewTypeChanged(Environment* ev, ODFrame* frame);
  138.     void        FrameShapeChanged(Environment* ev, ODFrame* frame);
  139.     ODID        Open(Environment* ev, ODFrame* frame);
  140.         
  141.     // -- Imaging --
  142.     
  143.     void        Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
  144.     void        GeometryChanged(Environment* ev, ODFacet* facet,
  145.                                         ODBoolean clipShapeChanged,
  146.                                         ODBoolean externalTransformChanged);
  147.     void        HighlightChanged(Environment* ev, ODFacet* facet);
  148.     void        FacetAdded(Environment* ev, ODFacet* facet);
  149.     void        FacetRemoved(Environment* ev, ODFacet* facet);
  150.     
  151.     // -- Activation --
  152.     
  153.     ODBoolean    BeginRelinquishFocus(Environment* ev, ODTypeToken focus,
  154.                                         ODFrame* ownerFrame,
  155.                                         ODFrame* proposedFrame);
  156.     void        CommitRelinquishFocus(Environment* ev, ODTypeToken focus,
  157.                                         ODFrame* ownerFrame,
  158.                                         ODFrame* proposedFrame);
  159.     void        AbortRelinquishFocus(Environment* ev, ODTypeToken focus,
  160.                                         ODFrame* ownerFrame,
  161.                                         ODFrame* proposedFrame);
  162.     void        FocusAcquired(Environment* ev,ODTypeToken focus,
  163.                                         ODFrame* ownerFrame);
  164.     void        FocusLost(Environment* ev,ODTypeToken focus,
  165.                                         ODFrame* ownerFrame);
  166.     
  167.     // -- Event Handling --
  168.     
  169.     ODBoolean    HandleEvent(Environment* ev, ODEventData* event,
  170.                                         ODFrame* frame, ODFacet* facet,
  171.                                         ODEventInfo* eventInfo);
  172.     void        AdjustMenus(Environment* ev, ODFrame* frame);
  173.     
  174.     
  175.       //===================================
  176.     // Newly Introduced Internal Methods
  177.       //===================================
  178.     protected:
  179.     
  180.     // -- Initialization --
  181.     
  182.     void        Initialize(Environment* ev, ACF_DevServ_som_ListPart* somSelf);
  183.     
  184.     // -- Storage --
  185.     
  186.     void        CheckAndAddProperties(Environment* ev,
  187.                                         ODStorageUnit* storageUnit);
  188.     void        CleanseContentProperty(Environment* ev,
  189.                                         ODStorageUnit* storageUnit);
  190.     void        InternalizeStateInfo(Environment* ev,
  191.                                         ODStorageUnit* storageUnit);
  192.     void        InternalizeContent(Environment* ev,
  193.                                         ODStorageUnit* storageUnit);
  194.     void        ExternalizeStateInfo(Environment* ev,
  195.                                         ODStorageUnit* storageUnit,
  196.                                         ODDraftKey key, ODFrame* scopeFrame);
  197.     void        ExternalizeContent(Environment* ev, ODStorageUnit* storageUnit,
  198.                                         ODDraftKey key, ODFrame* scopeFrame);
  199.     void        SetDirty(Environment* ev);
  200.     
  201.     // -- Event Handling --
  202.     
  203.     ODBoolean    HandleMenuEvent(Environment* ev, ODEventData* event,
  204.                                            ODFrame* frame);
  205.     ODBoolean    HandleMouseEvent(Environment* ev, ODEventData* event,
  206.                                         ODFacet* facet, ODEventInfo* eventInfo);
  207.     void        DoMouseEvent(Environment* ev, ODEventData* event, ODFacet* facet, Point* where);
  208.     void        DoDialogBox(Environment* ev, ODFrame* frame,
  209.                                           ODSShort dialogID, ODUShort errorNumber = 0);
  210.     
  211.     // -- Imaging --
  212.     
  213.     void        DrawFrameView(Environment* ev, ODFacet* facet);
  214.     void        DrawIconView(Environment* ev, ODFacet* facet);
  215.     void        DrawThumbnailView(Environment* ev, ODFacet* facet);
  216.     void        GenerateThumbnail( Environment*    ev, ODFrame* frame );
  217.     
  218.     // -- Activation --
  219.     
  220.     void        PartActivated(Environment* ev, ODFrame* frame);
  221.     ODBoolean    ActivateFrame(Environment* ev, ODFrame* frame, ODFacet* facet);
  222.     void        WindowActivating(Environment* ev, ODFrame* frame,
  223.                                         ODBoolean activating, ODFacet* facet);
  224.     void        RelinquishAllFoci(Environment* ev, ODFrame* frame);
  225.     
  226.     // -- Layout --
  227.     
  228.     ODWindow*    AcquireFramesWindow(Environment* ev, ODFrame* frame);
  229.     ODWindow*    CreateWindow(Environment* ev, ODFrame* frame, ODType frameType,
  230.                                         WindowProperties* windowProperties);
  231.     void        CleanupWindow(Environment* ev, ODFrame* frame);
  232.     WindowProperties*    GetDefaultWindowProperties(Environment* ev, ODFrame* frame,
  233.                                         Rect* windowRect);
  234.     WindowProperties*    GetSavedWindowProperties(Environment* ev, ODFrame* frame);
  235.     Rect        CalcPartWindowSize(Environment* ev, ODFrame* sourceFrame);
  236.     Rect        CalcPartWindowPosition(Environment* ev, ODFrame* frame,
  237.                                         Rect* partWindowBounds);
  238.     ODFacet*    GetActiveFacetForFrame(Environment* ev, ODFrame* frame);
  239.     ODShape*    CalcNewUsedShape(Environment* ev, ODFrame* frame);
  240.     void        UpdateFrame(Environment* ev, ODFrame* frame, ODTypeToken view,
  241.                                         ODShape* usedShape);
  242.     void        CleanupDisplayFrame(Environment* ev, ODFrame* frame,
  243.                                         ODBoolean frameRemoved);
  244.                                         
  245. // ES 11/13/95
  246.     // • Mine… •
  247.     public:
  248.  
  249.     void            HandleMouseDownInList(Environment* ev, ODEventData* event, ODFacet* facet, Point macPoint);
  250.     void            TheControlAction(Environment* ev, ODFacet* theFacet, ControlHandle theControl, short thePart);
  251.     void            TheControlThumbAction(Environment* ev, ODFacet* theFacet, ControlHandle theControl);
  252.     void            DrawMultCell(Environment* ev, ODFacet* facet, short firstLine, short lastLine);
  253.     void            DrawCell(Environment* ev, ODFacet* facet, short theLine);
  254.     void            CopyFromGWorld(Environment* ev, ODFacet* facet);
  255.     void            ScrollTo(Environment* ev, ODFacet* facet, short whereto);
  256.     void            CloseCellOpened(Environment* ev);
  257.     void            NewSel(Environment* ev, ODFacet* facet, short whereto, short wherefrom, char tosel);
  258.     short            FirstClick(Environment* ev, ODFacet* facet, ODEventData* event, short* where, char* val, Point macPoint);
  259.     void            StillClick(Environment* ev, ODFacet* facet, short where, char val);
  260.     short            ClickWithMod(Environment* ev, ODFacet* facet, ODEventData* event);
  261.     short            KeyInList(Environment* ev, char theChar);
  262.     void            ExternalizeListParams(Environment* ev, ODStorageUnit* storageUnit);
  263.     void            InternalizeListParams(Environment* ev, ODStorageUnit* storageUnit);
  264.     void            SetUpListParams(Environment* ev, ODStorageUnit* storageUnit);
  265.  
  266. // to call
  267.     void            ShowMe(Environment* ev, ODFacet* facet, short theLine);
  268.     short            GetNbLines(Environment* ev);
  269.     void            SetNbLines(Environment* ev, short newNbLines);
  270.     void            SetSel(Environment* ev, ODFacet* facet, short theLine);
  271.     short            GetSel(Environment* ev);
  272.  
  273. // to override
  274.     ODISOStr        GetTheRealPartKind(Environment* ev);
  275.     ODSLong            OverrideBeginUsingLibraryResources(Environment* ev);
  276.     void            OverrideEndUsingLibraryResources(Environment* ev, ODSLong ref);
  277.  
  278.     void            SetUpGraphics(Environment* ev, GWorldPtr theGWorld);
  279.     void            FillCell(Environment* ev, short theLine, Rect* theRect);
  280.     void            FillHilCell(Environment* ev, short theLine, Rect* theRect);
  281.     void            ClickInActive(Environment* ev, ODFacet* facet, ODEventData* event, Rect* theRect);
  282.     void            CloseOpenedCell(Environment* ev, ODFacet* facet);
  283.     void            IdleOpened(Environment* ev, ODFacet* facet);
  284.     short            KeyInActive(Environment* ev, ODFacet* facet, ODEventData* event);
  285.     short            KeyShortCut(Environment* ev, char theChar);
  286.     void            GotDoubleClick(Environment* ev, ODFacet* facet, short theLine);
  287.     void            ExternalizeListData(Environment* ev, ODStorageUnit* storageUnit);
  288.     void            InternalizeListData(Environment* ev, ODStorageUnit* storageUnit);
  289.     void            SetUpListData(Environment* ev, ODStorageUnit* storageUnit);
  290.     void            InitializeListData(Environment* ev,
  291.                                             short* pNbLines,
  292.                                             short* pLineHeight,
  293.                                             short* pLineWidth,
  294.                                             short* pLineDepth,
  295.                                             short* pKind,
  296.                                             short* pAutoThumb,
  297.                                             short* pWantKey,
  298.                                             short* pListIndex,
  299.                                             short* pSel,
  300.                                             char** pMul);
  301.     
  302.     protected:
  303.  
  304.     void        AdjustFacets(Environment* ev, ODFrame* frame);
  305.     void        MyAdjustRectFacet(Environment* ev, Rect* theRect);
  306.     void        MyAdjustCtlFacet(Environment* ev, ODFacet* facet);
  307.     void        MyAdjustGWFacet(Environment* ev, ODFacet* facet);
  308.  
  309.       //========================
  310.     private:
  311.  
  312.     CList*        fDisplayFrames;
  313.     ODBoolean    fDirty;
  314.     ODPart*        fSelf;
  315.     ODBoolean    fReadOnlyStorage;
  316.  
  317. // ES 11/15/95
  318.     // • Mine… •
  319.     ACF_DevServ_som_ListPart*    fsomSelf;
  320.     Handle                        fThumbnail;
  321.     ODFacet*                    fOpenedFacet;
  322.     ODFacet*                    fFocusedFacet;
  323.     short                        fListIndex;
  324.     short                        fNbLines;
  325.     short                        fLineHeight;
  326.     short                        fLineWidth;
  327.     short                        fLineDepth;
  328.     short                        fAutoThumb;
  329.     short                        fKind;
  330.     short                        fLineOpened;
  331.     short                        fSel;
  332.     char*                        fMul;
  333.     short                        fWantKey;
  334.     GWorldPtr                    fGWorld;
  335.     short                        fGWNbLines;
  336.     long                        fLastClickTime;
  337.     short                        fLastClickedLine;
  338.     short                        fDoubleClickedLine;
  339. };
  340.  
  341. #pragma import off
  342.  
  343. #endif